﻿using System;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.Text;

namespace TestWebApplication
{
    public abstract class ServiceAdapter
    {
        private string remoteUrl;
        private string certLocation;
        private string password;

        protected BasicHttpBinding binding;
        protected EndpointAddress address;
        protected X509Certificate2 clientCert;

        public ServiceAdapter(string serviceUrl, X509Certificate2 cert)
        {
            this.remoteUrl = serviceUrl;
            this.clientCert = cert;
        }

        public void Initialize()
        {
            this.binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            this.binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
            this.binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
            this.binding.Security.Transport.Realm = string.Empty;
            this.binding.ReaderQuotas.MaxDepth = 2147483647;
            this.binding.ReaderQuotas.MaxStringContentLength = 2147483647;

            // Setup Endpoint
            this.address = new EndpointAddress(this.remoteUrl);
            
            //this.clientCert = new X509Certificate2("D:\\CertTool.pfx", "password");
            //X509Certificate2 cert = new X509Certificate2("D:\\CertTool.pfx", "password");
           
            

        }
    }
}
